/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edi.entities;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.joda.time.DateTime;
import org.springframework.data.domain.Auditable;

/**
 *
 * @author Kamil
 */
@Entity
@Table(name = "T_DOC_HISTORY")
@Where(clause = "DCH_AUDIT_RD IS NULL")
@NamedQueries({
    @NamedQuery(name = "DocHistory.findByFileId", query = "SELECT p FROM DocHistoryEntity p WHERE p.dchDocId = :dchDocId")})
public class DocHistoryEntity implements Auditable<Long, Long>, Serializable {

    private static final long serialVersionUID = 4169965461802955798L;

    @Id
    @SequenceGenerator(name = "doc_history_sequence", sequenceName = "S_DCT_ID", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "doc_history_sequence")
    @Column(name = "DCH_ID")
    private Long dchId;
    
    @Column(name = "DCH_DOC_ID")
    private Long dchDocId;


    @Column(length = 100, name = "DCH_COMMENT")
    private String dchComment;
    
    @Column(length = 100, name = "DCH_DOC_NAME")
    private String dchDocName;

    @Column(name = "DCH_DOC_CONTENT")
    private byte[] dchDocContent;

    @Column(name = "DCH_DOC_DCT_ID")
    private Long dchDocDctId;
    
    
    
    @Column(name = "DCH_AUDIT_CD")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime createdDate;
    
    @Column(name = "DCH_AUDIT_CU")
    private Long createUser;
    
    @Column(name = "DCH_AUDIT_MD")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime modifiedDate;
    
    @Column(name = "DCH_AUDIT_MU")
    private Long modifiedUser;
    
    @Column(name = "DCH_AUDIT_RD")
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @SuppressWarnings("unused")
    private DateTime removeDate;
    
    @Column(name = "DCH_AUDIT_RU")
    @SuppressWarnings("unused")
    private Long removeUser;
    
    
    public Long getDchId() {
        return dchId;
    }


    public String getDchComment() {
        return dchComment;
    }

    public void setDchComment(String dchComment) {
        this.dchComment = dchComment;
    }

    public String getDchDocName() {
        return dchDocName;
    }

    public void setDchDocName(String dchDocName) {
        this.dchDocName = dchDocName;
    }

    public byte[] getDchDocContent() {
        return dchDocContent;
    }

    public void setDchDocContent(byte[] dchDocContent) {
        this.dchDocContent = dchDocContent;
    }

    public Long getDchDocDctId() {
        return dchDocDctId;
    }

    public void setDchDocDctId(Long dchDocDctId) {
        this.dchDocDctId = dchDocDctId;
    }

    public Long getDchDocId() {
        return dchDocId;
    }

    public void setDchDocId(Long dchDocId) {
        this.dchDocId = dchDocId;
    }
    
    
    @Override
    public boolean isNew() {
        return (dchId == null);
    }
    
     @Override
     public int hashCode() {
     return HashCodeBuilder.reflectionHashCode(this);
     }

     @Override
     public boolean equals(Object o) {
     return EqualsBuilder.reflectionEquals(this, o);
     }

     @Override
     public String toString() {
     return "id=" + dchId.toString() + ", docHistoryComment=" + dchComment + ", docHistoryName=" + dchDocName;
     }
    

    @Override
    public Long getId() {
        return dchId;
    }
    
    @Override
    public Long getCreatedBy() {
      return createUser;
    }
    
    @Override
    public void setCreatedBy(Long u) {
        createUser = u;
    }

    @Override
    public org.joda.time.DateTime getCreatedDate() {
    return createdDate;
    }

    @Override
    public void setCreatedDate(org.joda.time.DateTime dt) {
       createdDate = dt;
    }

    @Override
    public Long getLastModifiedBy() {
        return modifiedUser;
    }

    @Override
    public void setLastModifiedBy(Long u) {
       modifiedUser = u;
    }

    @Override
    public org.joda.time.DateTime getLastModifiedDate() {
        return modifiedDate;
    }

    @Override
    public void setLastModifiedDate(org.joda.time.DateTime dt) {
        modifiedDate = dt;
    }
    
    public void setRemoveDate(org.joda.time.DateTime dt) {
        removeDate = dt;
    }
           
    public void setRemovedBy(Long u) {
       removeUser = u;
    }
}
